package Projektarbete;

import java.io.Serializable;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import staticClasses.DBConn;
import staticClasses.IP;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import staticClasses.DBConn;
import staticClasses.IP;

public class User implements Serializable, Comparable<User> {
	private int u_id;
	private String userName;
	private String password;
	private String firstName;
	private String lastName;
	private String email;
	private String ip;
	private int ssn;
	private boolean isOnline;
	
	
	/**
	 * 
	 * 
	 * @param userName
	 * @param firstName
	 * @param lastName
	 * @param email
	 * @param password
	 * @param ssn
	 */
	public User(String userName, String firstName, String lastName,
			String email, String password, int ssn) {

		this.userName = userName;
		this.firstName = firstName;
		this.lastName = lastName;
		this.email = email;
		this.password = password;
		this.ssn = ssn;
		this.ip = IP.getServerIP();
		isOnline = false;

	}

	/**
	 * This method is being called from by the database only. It's for creating a User object that's being received as a contact by 
	 * 
	 * @param u_id
	 * @param userName
	 * @param firstName
	 * @param lastName
	 * @param email
	 * @param ip
	 * @param ssn
	 * @param isOnline
	 */
	public User(int u_id, String userName, String ip, boolean isOnline, String firstName, String lastName,
			String email, int ssn) {
		super();
		this.u_id = u_id;
		this.userName = userName;
		this.firstName = firstName;
		this.lastName = lastName;
		this.email = email;
		this.ip = ip;
		this.ssn = ssn;
		this.isOnline = isOnline;
	}


	public int getU_id() {
		return u_id;
	}

	public void setU_id(int u_id) {
		this.u_id = u_id;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public int getSsn() {
		return ssn;
	}

	public void setSsn(int ssn) {
		this.ssn = ssn;
	}

	public boolean isOnline() {
		return isOnline;
	}

	public void setOnline(boolean isOnline) {
		this.isOnline = isOnline;
	}

	@Override
	public String toString() {
		return "User [u_id=" + u_id + ", userName=" + userName + ", password="
				+ password + ", firstName=" + firstName + ", lastName="
				+ lastName + ", email=" + email + ", ip=" + ip + ", ssn=" + ssn
				+ ", isOnline=" + isOnline + "]\n";
	}

	@Override
	public int compareTo(User o) {		
		return userName.compareTo(o.getUserName());
	}


}
